<?php
require_once('security.php');
  
  $page = $_GET['page'];
  echo '<h3>Existing Items</h3>';

  echo '<div id="php" style="width:100%;">';
  echo '<p><b>Category Items (click to edit):</b></p>';
  echo "\n<ul>\n";
  $filename = "../textfiles/" . $page . ".txt";
  $fd = fopen ($filename, "r");
  $contents = fread ($fd,filesize($filename));
  fclose ($fd); 
  
  $splitcontents = explode("\n", $contents);
  $counter = 0; 
  foreach ($splitcontents as $value) 
  {
      $items[$counter] = explode("|", $value);
      $counter++;
  }
  $sizeof_arr = sizeof($items);
    
  for ($i=0; $i<$sizeof_arr; $i++)
  {
    echo '<li><a href="write.php?page=' . $page . '&name='. $items[$i][1] .'&cost=' . $items[$i][2] . '" title="Edit">';
    echo  $items[$i][1];
    echo  "<b> " . $items[$i][2];
    echo  "</b></a></li>"; 
  }
                                                                                                        
  echo "\n</ul>\n";
  echo '</div>';
?>
